/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink;

import com.xpstem.lelink.command.EV3Command;
import com.xpstem.lelink.command.EV3ReplyCallback;
import com.xpstem.lelink.device.EV3InputDevice;
import com.xpstem.lelink.device.EV3Sensor;
import com.xpstem.lelink.enums.InputPort;
import com.xpstem.lelink.enums.Layer;

/**
 * Event bus.
 *
 * @author billy zhang
 */
public interface EventBus {

    Layer getLayer();

    /**
     * Execute ev3 command.
     *
     * @param command Command instance
     */
    void postCommand(EV3Command command);

    /**
     * Execute ev3 command, async callback.
     *
     * @param command Command instance
     */
    void postCommand(EV3Command command, EV3ReplyCallback callback);

    /**
     * Sensor value changed.
     *
     * @param portNo Input port no
     * @param sensor EV3 sensor
     */
    void onSensorChanged(InputPort portNo, EV3Sensor sensor);

    /**
     * Sensor lost
     *
     * @param portNo Input port no
     * @param device EV3 input device
     */
    void onDeviceLost(InputPort portNo, EV3InputDevice device);
}
